<ion-view view-title={{moduleTitle}}>
    <ion-nav-buttons side="left">
        <a class="button button-icon ion-arrow-left-c" ng-click="goBack()"></a>
    </ion-nav-buttons>
    <div class="tabs-striped tabs-top">
        <div class="tabs">
            <a ng-if="access.list" ng-class="{'tab-item':true,'active': id }" href="#/{{moduleName}}/list">查看</a>
            <a ng-if="access.add" ng-class="{'tab-item':true,'active': !id }" href="#/{{moduleName}}/0">添加</a>
            <a ng-if="access.stats" ng-class="{'tab-item':true,'active': false }" href="#/{{moduleName}}/stats">统计</a>
        </div>
    </div>
    <ion-content class="padding has-tabs-top">
        <form name="detailForm" novalidate="" ng-submit="submitForm(detailForm)">
            <div class="list">
                <insert-date form="detailForm" dateoption="dateOption"></insert-date>

                <label class="item item-input">
                    <span class="input-label">发票编号<span style="color:red">*</span>：</span>
                    <input type="text" name="invoice_id" ng-model="detail.invoice_id"
                           ng-maxlength="10"
                           required
                           ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                </label>
                <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                     ng-messages="detailForm.invoice_id.$error" role="alert">
                    <div ng-messages-include="invoice-detail-maxlength-10-errors.html"></div>
                </div>

                <insert-select form="detailForm" option="distributorOption"></insert-select>
                <insert-select form="detailForm" option="salesmanOption"></insert-select>
                <insert-select form="detailForm" option="salesTypeOption"></insert-select>
                <insert-select form="detailForm" option="sacfvarietyOption"></insert-select>
                <label class="item item-input">
                    <span class="input-label">数量<span style="color: red;">*</span>：</span>
                    <input type="text" name="quantity" ng-model="detail.quantity"
                           required
                           ng-pattern='/^\d{1,8}([\.]\d{0,2})?$/'
                           ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                </label>

                <!-- Error Container for Password -->
                <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                     ng-messages="detailForm.quantity.$error" role="alert">
                    <div ng-messages-include="templates/system-templates/detail-errors.html"></div>
                </div>
                <insert-address  form="detailForm" addressoption="addressOption"></insert-address>
                <label class="item item-input">
                    <span class="input-label">到站地名：</span>
                    <input type="text" name="station_name" ng-model="detail.station_name"
                           ng-maxlength="10"
                           ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                </label>
                <!-- Error Container for Password -->
                <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                     ng-messages="detailForm.this_month_stock.$error" role="alert">
                    <div ng-messages-include="invoice-detail-maxlength-10-errors.html"></div>
                </div>

                <label class="item item-input">
                    <span class="input-label">路局：</span>
                    <input type="text" name="railway_bureau" ng-model="detail.railway_bureau"
                           ng-maxlength="10"
                           ng-model-options="{ updateOn: 'default blur', debounce: { default: 500, blur: 0 } }">
                </label>
                <!-- Error Container for Password -->
                <div class="validation-error" ng-class="{'is-dirty':form.password.$dirty}"
                     ng-messages="detailForm.this_month_stock.$error" role="alert">
                    <div ng-messages-include="invoice-detail-maxlength-10-errors.html"></div>
                </div>
                <label  class="item item-input item-select">
                    <span class="input-label">关内/关外</span>
                    <select ng-model="inoroutOption.value"
                            ng-options="value.id as value.label for value in inoroutOption.inoroutSource">
                    </select>
                </label>

            </div>
            <button class="button button-full button-positive" ng-disabled="detailForm.$invalid || detailEdit.editDisabled" type="submit">
                {{operation}}
            </button>
        </form>
    </ion-content>

    <script id="invoice-detail-maxlength-10-errors.html" type="text/ng-template">
        <div class="error" ng-message="maxlength">
            <i class="ion-information-circled"></i> 字符长度不能超过10个
        </div>
    </script>
    <!--头部和内容结束-->
</ion-view>